<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: hardware_adc</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.1.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__hardware__adc.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">hardware_adc<div class="ingroups"><a class="el" href="group__hardware.html">Hardware APIs</a></div></div></div>
</div><!--header-->
<div class="contents">

<p>Analog to Digital Converter (ADC) API.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga2b815e6730e8723a6d1d06d9ef8f31c0"><td class="memItemLeft" align="right" valign="top"><a id="ga2b815e6730e8723a6d1d06d9ef8f31c0" name="ga2b815e6730e8723a6d1d06d9ef8f31c0"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>adc_init</b> (void)</td></tr>
<tr class="memdesc:ga2b815e6730e8723a6d1d06d9ef8f31c0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialise the ADC HW. <br /></td></tr>
<tr class="separator:ga2b815e6730e8723a6d1d06d9ef8f31c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab15d6e804715935b4e9b5027a2940910"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#gab15d6e804715935b4e9b5027a2940910">adc_gpio_init</a> (uint gpio)</td></tr>
<tr class="memdesc:gab15d6e804715935b4e9b5027a2940910"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialise the gpio for use as an ADC pin.  <a href="group__hardware__adc.html#gab15d6e804715935b4e9b5027a2940910">More...</a><br /></td></tr>
<tr class="separator:gab15d6e804715935b4e9b5027a2940910"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5d3b8875947df2f4ba022cb6aa40594b"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga5d3b8875947df2f4ba022cb6aa40594b">adc_select_input</a> (uint input)</td></tr>
<tr class="memdesc:ga5d3b8875947df2f4ba022cb6aa40594b"><td class="mdescLeft">&#160;</td><td class="mdescRight">ADC input select.  <a href="group__hardware__adc.html#ga5d3b8875947df2f4ba022cb6aa40594b">More...</a><br /></td></tr>
<tr class="separator:ga5d3b8875947df2f4ba022cb6aa40594b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga84b5f9054de9c00d51095c9bdefb2dca"><td class="memItemLeft" align="right" valign="top">static uint&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga84b5f9054de9c00d51095c9bdefb2dca">adc_get_selected_input</a> (void)</td></tr>
<tr class="memdesc:ga84b5f9054de9c00d51095c9bdefb2dca"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the currently selected ADC input channel.  <a href="group__hardware__adc.html#ga84b5f9054de9c00d51095c9bdefb2dca">More...</a><br /></td></tr>
<tr class="separator:ga84b5f9054de9c00d51095c9bdefb2dca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga16d25be75e16f0671d3e3185b0b59771"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga16d25be75e16f0671d3e3185b0b59771">adc_set_round_robin</a> (uint input_mask)</td></tr>
<tr class="memdesc:ga16d25be75e16f0671d3e3185b0b59771"><td class="mdescLeft">&#160;</td><td class="mdescRight">Round Robin sampling selector.  <a href="group__hardware__adc.html#ga16d25be75e16f0671d3e3185b0b59771">More...</a><br /></td></tr>
<tr class="separator:ga16d25be75e16f0671d3e3185b0b59771"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga33f302059e05899d1709d6268d75972b"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga33f302059e05899d1709d6268d75972b">adc_set_temp_sensor_enabled</a> (bool enable)</td></tr>
<tr class="memdesc:ga33f302059e05899d1709d6268d75972b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enable the onboard temperature sensor.  <a href="group__hardware__adc.html#ga33f302059e05899d1709d6268d75972b">More...</a><br /></td></tr>
<tr class="separator:ga33f302059e05899d1709d6268d75972b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf32d82a43103e6672048001f58d5f6fb"><td class="memItemLeft" align="right" valign="top">static uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#gaf32d82a43103e6672048001f58d5f6fb">adc_read</a> (void)</td></tr>
<tr class="memdesc:gaf32d82a43103e6672048001f58d5f6fb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Perform a single conversion.  <a href="group__hardware__adc.html#gaf32d82a43103e6672048001f58d5f6fb">More...</a><br /></td></tr>
<tr class="separator:gaf32d82a43103e6672048001f58d5f6fb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5d50a24eb26da7fbc6ee9bc76723b09c"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga5d50a24eb26da7fbc6ee9bc76723b09c">adc_run</a> (bool run)</td></tr>
<tr class="memdesc:ga5d50a24eb26da7fbc6ee9bc76723b09c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enable or disable free-running sampling mode.  <a href="group__hardware__adc.html#ga5d50a24eb26da7fbc6ee9bc76723b09c">More...</a><br /></td></tr>
<tr class="separator:ga5d50a24eb26da7fbc6ee9bc76723b09c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga333f7ca46a11241d96d0a4c24f0d4bb0"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga333f7ca46a11241d96d0a4c24f0d4bb0">adc_set_clkdiv</a> (float clkdiv)</td></tr>
<tr class="memdesc:ga333f7ca46a11241d96d0a4c24f0d4bb0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the ADC Clock divisor.  <a href="group__hardware__adc.html#ga333f7ca46a11241d96d0a4c24f0d4bb0">More...</a><br /></td></tr>
<tr class="separator:ga333f7ca46a11241d96d0a4c24f0d4bb0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2a6fa32da04e65a027e14deaf32b8f10"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga2a6fa32da04e65a027e14deaf32b8f10">adc_fifo_setup</a> (bool en, bool dreq_en, uint16_t dreq_thresh, bool err_in_fifo, bool byte_shift)</td></tr>
<tr class="memdesc:ga2a6fa32da04e65a027e14deaf32b8f10"><td class="mdescLeft">&#160;</td><td class="mdescRight">Setup the ADC FIFO.  <a href="group__hardware__adc.html#ga2a6fa32da04e65a027e14deaf32b8f10">More...</a><br /></td></tr>
<tr class="separator:ga2a6fa32da04e65a027e14deaf32b8f10"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafdfd586e6c26ffe4759afaa3c3f95465"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#gafdfd586e6c26ffe4759afaa3c3f95465">adc_fifo_is_empty</a> (void)</td></tr>
<tr class="memdesc:gafdfd586e6c26ffe4759afaa3c3f95465"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check FIFO empty state.  <a href="group__hardware__adc.html#gafdfd586e6c26ffe4759afaa3c3f95465">More...</a><br /></td></tr>
<tr class="separator:gafdfd586e6c26ffe4759afaa3c3f95465"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafa9793deea59c5cbfea147e0e9d895c3"><td class="memItemLeft" align="right" valign="top">static uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#gafa9793deea59c5cbfea147e0e9d895c3">adc_fifo_get_level</a> (void)</td></tr>
<tr class="memdesc:gafa9793deea59c5cbfea147e0e9d895c3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of entries in the ADC FIFO.  <a href="group__hardware__adc.html#gafa9793deea59c5cbfea147e0e9d895c3">More...</a><br /></td></tr>
<tr class="separator:gafa9793deea59c5cbfea147e0e9d895c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga689d64744e7fe5284562569b24e9d624"><td class="memItemLeft" align="right" valign="top">static uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga689d64744e7fe5284562569b24e9d624">adc_fifo_get</a> (void)</td></tr>
<tr class="memdesc:ga689d64744e7fe5284562569b24e9d624"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get ADC result from FIFO.  <a href="group__hardware__adc.html#ga689d64744e7fe5284562569b24e9d624">More...</a><br /></td></tr>
<tr class="separator:ga689d64744e7fe5284562569b24e9d624"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga61553375ecc9275fa14c6ff7792a1506"><td class="memItemLeft" align="right" valign="top">static uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#ga61553375ecc9275fa14c6ff7792a1506">adc_fifo_get_blocking</a> (void)</td></tr>
<tr class="memdesc:ga61553375ecc9275fa14c6ff7792a1506"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait for the ADC FIFO to have data.  <a href="group__hardware__adc.html#ga61553375ecc9275fa14c6ff7792a1506">More...</a><br /></td></tr>
<tr class="separator:ga61553375ecc9275fa14c6ff7792a1506"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad637d97583f2c24e4159dc22bf17eaf2"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#gad637d97583f2c24e4159dc22bf17eaf2">adc_fifo_drain</a> (void)</td></tr>
<tr class="memdesc:gad637d97583f2c24e4159dc22bf17eaf2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Drain the ADC FIFO.  <a href="group__hardware__adc.html#gad637d97583f2c24e4159dc22bf17eaf2">More...</a><br /></td></tr>
<tr class="separator:gad637d97583f2c24e4159dc22bf17eaf2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf8e363e63f40e00c169f7355c9668681"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__adc.html#gaf8e363e63f40e00c169f7355c9668681">adc_irq_set_enabled</a> (bool enabled)</td></tr>
<tr class="memdesc:gaf8e363e63f40e00c169f7355c9668681"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enable/Disable ADC interrupts.  <a href="group__hardware__adc.html#gaf8e363e63f40e00c169f7355c9668681">More...</a><br /></td></tr>
<tr class="separator:gaf8e363e63f40e00c169f7355c9668681"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p >Analog to Digital Converter (ADC) API. </p>
<p >RP-series microcontrollers have an internal analogue-digital converter (ADC) with the following features:</p><ul>
<li>SAR ADC</li>
<li>500 kS/s (Using an independent 48MHz clock)</li>
<li>12 bit (RP2040 8.7 ENOB, RP2350 9.2 ENOB) </li>
<li>RP2040 5 input mux:<ul>
<li>4 inputs that are available on package pins shared with GPIO[29:26]</li>
<li>1 input is dedicated to the internal temperature sensor</li>
<li>4 element receive sample FIFO </li>
</ul>
</li>
</ul>
<ul>
<li>RP2350 5 or 9 input mux:<ul>
<li>4 inputs available on QFN-60 package pins shared with GPIO[29:26]</li>
<li>8 inputs available on QFN-80 package pins shared with GPIO[47:40]</li>
<li>8 element receive sample FIFO </li>
</ul>
</li>
<li>One input dedicated to the internal temperature sensor (see Section 12.4.6)</li>
<li>Interrupt generation</li>
<li>DMA interface</li>
</ul>
<p >Although there is only one ADC you can specify the input to it using the <a class="el" href="group__hardware__adc.html#ga5d3b8875947df2f4ba022cb6aa40594b" title="ADC input select.">adc_select_input()</a> function. In round robin mode (<a class="el" href="group__hardware__adc.html#ga16d25be75e16f0671d3e3185b0b59771" title="Round Robin sampling selector.">adc_set_round_robin()</a>), the ADC will use that input and move to the next one after a read.</p>
<p >RP2040, RP2350 QFN-60: User ADC inputs are on 0-3 (GPIO 26-29), the temperature sensor is on input 4. RP2350 QFN-80 : User ADC inputs are on 0-7 (GPIO 40-47), the temperature sensor is on input 8.</p>
<p >Temperature sensor values can be approximated in centigrade as:</p>
<p >T = 27 - (ADC_Voltage - 0.706)/0.001721</p>
<h2><a class="anchor" id="adc_example"></a>
Example</h2>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="stdio_8h.html">stdio.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="stdlib_8h.html">pico/stdlib.h</a>&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="gpio_8h.html">hardware/gpio.h</a>&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="rp2__common_2hardware__adc_2include_2hardware_2adc_8h.html">hardware/adc.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    <a class="code hl_function" href="group__pico__stdio.html#ga0e604311fb226dae91ff4eb17a19d67a">stdio_init_all</a>();</div>
<div class="line">    printf(<span class="stringliteral">&quot;ADC Example, measuring GPIO26\n&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <a class="code hl_function" href="group__hardware__adc.html#ga2b815e6730e8723a6d1d06d9ef8f31c0">adc_init</a>();</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Make sure GPIO is high-impedance, no pullups etc</span></div>
<div class="line">    <a class="code hl_function" href="group__hardware__adc.html#gab15d6e804715935b4e9b5027a2940910">adc_gpio_init</a>(26);</div>
<div class="line">    <span class="comment">// Select ADC input 0 (GPIO26)</span></div>
<div class="line">    <a class="code hl_function" href="group__hardware__adc.html#ga5d3b8875947df2f4ba022cb6aa40594b">adc_select_input</a>(0);</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">while</span> (1) {</div>
<div class="line">        <span class="comment">// 12-bit conversion, assume max value == ADC_VREF == 3.3 V</span></div>
<div class="line">        <span class="keyword">const</span> <span class="keywordtype">float</span> conversion_factor = 3.3f / (1 &lt;&lt; 12);</div>
<div class="line">        uint16_t result = <a class="code hl_function" href="group__hardware__adc.html#gaf32d82a43103e6672048001f58d5f6fb">adc_read</a>();</div>
<div class="line">        printf(<span class="stringliteral">&quot;Raw value: 0x%03x, voltage: %f V\n&quot;</span>, result, result * conversion_factor);</div>
<div class="line">        <a class="code hl_function" href="group__sleep.html#gae617a6842d4f3a192064c4354b88fcff">sleep_ms</a>(500);</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="ttc" id="agpio_8h_html"><div class="ttname"><a href="gpio_8h.html">gpio.h</a></div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga2b815e6730e8723a6d1d06d9ef8f31c0"><div class="ttname"><a href="group__hardware__adc.html#ga2b815e6730e8723a6d1d06d9ef8f31c0">adc_init</a></div><div class="ttdeci">void adc_init(void)</div><div class="ttdoc">Initialise the ADC HW.</div><div class="ttdef"><b>Definition:</b> adc.c:11</div></div>
<div class="ttc" id="agroup__hardware__adc_html_ga5d3b8875947df2f4ba022cb6aa40594b"><div class="ttname"><a href="group__hardware__adc.html#ga5d3b8875947df2f4ba022cb6aa40594b">adc_select_input</a></div><div class="ttdeci">static void adc_select_input(uint input)</div><div class="ttdoc">ADC input select.</div><div class="ttdef"><b>Definition:</b> adc.h:118</div></div>
<div class="ttc" id="agroup__hardware__adc_html_gab15d6e804715935b4e9b5027a2940910"><div class="ttname"><a href="group__hardware__adc.html#gab15d6e804715935b4e9b5027a2940910">adc_gpio_init</a></div><div class="ttdeci">static void adc_gpio_init(uint gpio)</div><div class="ttdoc">Initialise the gpio for use as an ADC pin.</div><div class="ttdef"><b>Definition:</b> adc.h:95</div></div>
<div class="ttc" id="agroup__hardware__adc_html_gaf32d82a43103e6672048001f58d5f6fb"><div class="ttname"><a href="group__hardware__adc.html#gaf32d82a43103e6672048001f58d5f6fb">adc_read</a></div><div class="ttdeci">static uint16_t adc_read(void)</div><div class="ttdoc">Perform a single conversion.</div><div class="ttdef"><b>Definition:</b> adc.h:175</div></div>
<div class="ttc" id="agroup__pico__stdio_html_ga0e604311fb226dae91ff4eb17a19d67a"><div class="ttname"><a href="group__pico__stdio.html#ga0e604311fb226dae91ff4eb17a19d67a">stdio_init_all</a></div><div class="ttdeci">bool stdio_init_all(void)</div><div class="ttdoc">Initialize all of the present standard stdio types that are linked into the binary.</div><div class="ttdef"><b>Definition:</b> stdio.c:200</div></div>
<div class="ttc" id="agroup__sleep_html_gae617a6842d4f3a192064c4354b88fcff"><div class="ttname"><a href="group__sleep.html#gae617a6842d4f3a192064c4354b88fcff">sleep_ms</a></div><div class="ttdeci">void sleep_ms(uint32_t ms)</div><div class="ttdoc">Wait for the given number of milliseconds before returning.</div><div class="ttdef"><b>Definition:</b> time.c:439</div></div>
<div class="ttc" id="arp2__common_2hardware__adc_2include_2hardware_2adc_8h_html"><div class="ttname"><a href="rp2__common_2hardware__adc_2include_2hardware_2adc_8h.html">adc.h</a></div></div>
<div class="ttc" id="astdio_8h_html"><div class="ttname"><a href="stdio_8h.html">stdio.h</a></div></div>
<div class="ttc" id="astdlib_8h_html"><div class="ttname"><a href="stdlib_8h.html">stdlib.h</a></div></div>
</div><!-- fragment --> <h2 class="groupheader">Function Documentation</h2>
<a id="gad637d97583f2c24e4159dc22bf17eaf2" name="gad637d97583f2c24e4159dc22bf17eaf2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad637d97583f2c24e4159dc22bf17eaf2">&#9670;&nbsp;</a></span>adc_fifo_drain()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_fifo_drain </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Drain the ADC FIFO. </p>
<p >Will wait for any conversion to complete then drain the FIFO, discarding any results. </p>

</div>
</div>
<a id="ga689d64744e7fe5284562569b24e9d624" name="ga689d64744e7fe5284562569b24e9d624"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga689d64744e7fe5284562569b24e9d624">&#9670;&nbsp;</a></span>adc_fifo_get()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static uint16_t adc_fifo_get </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get ADC result from FIFO. </p>
<p >Pops the latest result from the ADC FIFO. </p>

</div>
</div>
<a id="ga61553375ecc9275fa14c6ff7792a1506" name="ga61553375ecc9275fa14c6ff7792a1506"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga61553375ecc9275fa14c6ff7792a1506">&#9670;&nbsp;</a></span>adc_fifo_get_blocking()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static uint16_t adc_fifo_get_blocking </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Wait for the ADC FIFO to have data. </p>
<p >Blocks until data is present in the FIFO </p>

</div>
</div>
<a id="gafa9793deea59c5cbfea147e0e9d895c3" name="gafa9793deea59c5cbfea147e0e9d895c3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafa9793deea59c5cbfea147e0e9d895c3">&#9670;&nbsp;</a></span>adc_fifo_get_level()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static uint8_t adc_fifo_get_level </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get number of entries in the ADC FIFO. </p>
<p >On RP2040 the FIFO is 4 samples long.   On RP2350 the FIFO is 8 samples long. </p>
<p >This function will return how many samples are currently present. </p>

</div>
</div>
<a id="gafdfd586e6c26ffe4759afaa3c3f95465" name="gafdfd586e6c26ffe4759afaa3c3f95465"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafdfd586e6c26ffe4759afaa3c3f95465">&#9670;&nbsp;</a></span>adc_fifo_is_empty()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static bool adc_fifo_is_empty </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Check FIFO empty state. </p>
<dl class="section return"><dt>Returns</dt><dd>Returns true if the FIFO is empty </dd></dl>

</div>
</div>
<a id="ga2a6fa32da04e65a027e14deaf32b8f10" name="ga2a6fa32da04e65a027e14deaf32b8f10"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2a6fa32da04e65a027e14deaf32b8f10">&#9670;&nbsp;</a></span>adc_fifo_setup()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_fifo_setup </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>en</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>dreq_en</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>dreq_thresh</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>err_in_fifo</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>byte_shift</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Setup the ADC FIFO. </p>
<p >On RP2040 the FIFO is 4 samples long. </p>
<p >On RP2350 the FIFO is 8 samples long. </p>
<p >If a conversion is completed and the FIFO is full, the result is dropped.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">en</td><td>Enables write each conversion result to the FIFO </td></tr>
    <tr><td class="paramname">dreq_en</td><td>Enable DMA requests when FIFO contains data </td></tr>
    <tr><td class="paramname">dreq_thresh</td><td>Threshold for DMA requests/FIFO IRQ if enabled. </td></tr>
    <tr><td class="paramname">err_in_fifo</td><td>If enabled, bit 15 of the FIFO contains error flag for each sample </td></tr>
    <tr><td class="paramname">byte_shift</td><td>Shift FIFO contents to be one byte in size (for byte DMA) - enables DMA to byte buffers. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga84b5f9054de9c00d51095c9bdefb2dca" name="ga84b5f9054de9c00d51095c9bdefb2dca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga84b5f9054de9c00d51095c9bdefb2dca">&#9670;&nbsp;</a></span>adc_get_selected_input()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static uint adc_get_selected_input </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get the currently selected ADC input channel. </p>
<dl class="section return"><dt>Returns</dt><dd>The currently selected input channel.</dd></dl>
<p>On RP02040 0...3 are GPIOs 26...29 respectively. Input 4 is the onboard temperature sensor. </p>
<p >On RP2350A 0...3 are GPIOs 26...29 respectively. Input 4 is the onboard temperature sensor. On RP2350B 0...7 are GPIOs 40...47 respectively. Input 8 is the onboard temperature sensor.  </p>

</div>
</div>
<a id="gab15d6e804715935b4e9b5027a2940910" name="gab15d6e804715935b4e9b5027a2940910"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab15d6e804715935b4e9b5027a2940910">&#9670;&nbsp;</a></span>adc_gpio_init()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_gpio_init </td>
          <td>(</td>
          <td class="paramtype">uint&#160;</td>
          <td class="paramname"><em>gpio</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Initialise the gpio for use as an ADC pin. </p>
<p >Prepare a GPIO for use with ADC by disabling all digital functions.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">gpio</td><td>The GPIO number to use. Allowable GPIO numbers are 26 to 29 inclusive on RP2040 or RP2350A, 40-48 inclusive on RP2350B </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gaf8e363e63f40e00c169f7355c9668681" name="gaf8e363e63f40e00c169f7355c9668681"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf8e363e63f40e00c169f7355c9668681">&#9670;&nbsp;</a></span>adc_irq_set_enabled()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_irq_set_enabled </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>enabled</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Enable/Disable ADC interrupts. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">enabled</td><td>Set to true to enable the ADC interrupts, false to disable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gaf32d82a43103e6672048001f58d5f6fb" name="gaf32d82a43103e6672048001f58d5f6fb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf32d82a43103e6672048001f58d5f6fb">&#9670;&nbsp;</a></span>adc_read()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static uint16_t adc_read </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Perform a single conversion. </p>
<p >Performs an ADC conversion, waits for the result, and then returns it.</p>
<dl class="section return"><dt>Returns</dt><dd>Result of the conversion. </dd></dl>

</div>
</div>
<a id="ga5d50a24eb26da7fbc6ee9bc76723b09c" name="ga5d50a24eb26da7fbc6ee9bc76723b09c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5d50a24eb26da7fbc6ee9bc76723b09c">&#9670;&nbsp;</a></span>adc_run()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_run </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>run</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Enable or disable free-running sampling mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">run</td><td>false to disable, true to enable free running conversion mode. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga5d3b8875947df2f4ba022cb6aa40594b" name="ga5d3b8875947df2f4ba022cb6aa40594b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5d3b8875947df2f4ba022cb6aa40594b">&#9670;&nbsp;</a></span>adc_select_input()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_select_input </td>
          <td>(</td>
          <td class="paramtype">uint&#160;</td>
          <td class="paramname"><em>input</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>ADC input select. </p>
<p >Select an ADC input  On RP02040 0...3 are GPIOs 26...29 respectively. Input 4 is the onboard temperature sensor.   On RP2350A 0...3 are GPIOs 26...29 respectively. Input 4 is the onboard temperature sensor. On RP2350B 0...7 are GPIOs 40...47 respectively. Input 8 is the onboard temperature sensor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Input to select. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga333f7ca46a11241d96d0a4c24f0d4bb0" name="ga333f7ca46a11241d96d0a4c24f0d4bb0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga333f7ca46a11241d96d0a4c24f0d4bb0">&#9670;&nbsp;</a></span>adc_set_clkdiv()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_set_clkdiv </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>clkdiv</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Set the ADC Clock divisor. </p>
<p >Period of samples will be (1 + div) cycles on average. Note it takes 96 cycles to perform a conversion, so any period less than that will be clamped to 96.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">clkdiv</td><td>If non-zero, conversion will be started at intervals rather than back to back. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga16d25be75e16f0671d3e3185b0b59771" name="ga16d25be75e16f0671d3e3185b0b59771"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga16d25be75e16f0671d3e3185b0b59771">&#9670;&nbsp;</a></span>adc_set_round_robin()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_set_round_robin </td>
          <td>(</td>
          <td class="paramtype">uint&#160;</td>
          <td class="paramname"><em>input_mask</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Round Robin sampling selector. </p>
<p >This function sets which inputs are to be run through in round robin mode. RP2040, RP2350 QFN-60: Value between 0 and 0x1f (bit 0 to bit 4 for GPIO 26 to 29 and temperature sensor input respectively) RP2350 QFN-80: Value between 0 and 0xff (bit 0 to bit 7 for GPIO 40 to 47 and temperature sensor input respectively)</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input_mask</td><td>A bit pattern indicating which of the 5/8 inputs are to be sampled. Write a value of 0 to disable round robin sampling. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga33f302059e05899d1709d6268d75972b" name="ga33f302059e05899d1709d6268d75972b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga33f302059e05899d1709d6268d75972b">&#9670;&nbsp;</a></span>adc_set_temp_sensor_enabled()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void adc_set_temp_sensor_enabled </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>enable</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Enable the onboard temperature sensor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">enable</td><td>Set true to power on the onboard temperature sensor, false to power off. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>